/**
 * Package:com.goldcitynet.server.data;
 * $Id: SpringContextLoader.java,v 1.3 2008/10/31 01:25:34 zhangpei Exp $
 * Copyright(c) 2001-2005 www.afteryuan.com
 */
package com.afteryuan.server;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.BeanFactory;

/**
 * SpringContextLoader类 spring上下文装载器
 * <p/>
 * <p><a href="SpringContextLoader.java.html"><i>View Source</i></a></p>
 *
 * @author <a href="mailto:afteryuan@afteryuan.com">$Author: zhangpei $</a>
 * @version $Revision: 1.3 $
 */
public class SpringContextLoader {
    /**
     * spring上下文装载器对象
     */
    public static  SpringContextLoader springContextLoader;
    /**
     * spring上下文对象
     */
    private ApplicationContext context;

    /**
     * 获取唯一的spring上下文装载器对象
     * @return SpringContextLoader
     */
    public synchronized static  SpringContextLoader getInstance(){
        if(springContextLoader == null)springContextLoader = new SpringContextLoader();
        return springContextLoader;
    }

    /**
     * 获取spring上下文对象
     * @return BeanFactory
     */
    public BeanFactory getBeanFactory(){
        return context;
    }

    private SpringContextLoader(){
//        context = new ClassPathXmlApplicationContext( new String[] {"classpath*:spring/applicationContext-handler.xml"});
        context = new ClassPathXmlApplicationContext( new String[] {"classpath*:spring/application**.xml"});
        System.out.println("Spring contxet initialled !");
    }

}
